﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Configuration;
using Microsoft.Windows.Controls;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using Microsoft.Windows.Controls.Ribbon;


namespace ScrumMagic
{
    /// <summary>
    /// Interaction logic for UserCardForm.xaml
    /// </summary>
    /// 

    public partial class UserCardForm : ScrumMagic.CommonForm
    {
        int userId;

        public UserCardForm(int userId)
        {
            InitializeComponent();
            this.userId = userId;
        }

        //public override RibbonTab RibbonContextualTab
        //{
        //    get { return null; }
        //}

        private void CommonForm_Loaded(object sender, RoutedEventArgs e)
        {
            SqlCommand cmd = DBController.MainConnection.CreateCommand();
            cmd.CommandText = "SELECT Id, Login, FirstName, MiddleName, LastName, Email FROM dbo.[User] WHERE Id = @userId";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@userId", userId);
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable table = new DataTable();
            adapter.Fill(table);


            SqlDataReader reader = cmd.ExecuteReader();
                        
            while (reader.Read())
            {
                TitleLabel.Content = "User Card";
                LoginBox.Text = reader["Login"].ToString();
                FirstNameBox.Text = reader["FirstName"].ToString();
                MiddleNameBox.Text = reader["MiddleName"].ToString();
                LastNameBox.Text = reader["LastName"].ToString();
                EmailBox.Text = reader["Email"].ToString();
            }
            
            reader.Close();

        }

    }
}
